<?php
/**
 * Created by PhpStorm.
 * User: zhaojia
 * Date: 15-8-21
 * Time: 下午9:05
 */
namespace Admin\Controller;
use Think\Controller;
class TagController extends CommonController {

    private $_model;
    function _initialize(){
        $this->_model=D('Tag');
    }
    public function index(){
        $data=$this->_model->get_data();
        $this->assign('data',$data);
        $this->display();
    }

    public function add(){
        if(IS_POST){
            $data=$_POST;
            $this->_model->add_data($data);
        }
        $this->display();
    }

    public function edit(){
        if(IS_POST){
            $tid=$_POST['id'];
            $data=$_POST;
            $this->_model->save_data($where,$data);
            $this->error("修改成功",U('Tag/index'));
        }
        $tid=I('get.tid');
        $where=array('tid'=>$tid);
        $data=$this->_model->get_data($where);
        $this->assign('data',$data);
        $this->display();
    }

    public function del(){
        if(IS_GET){
            $tid=I('get.tid');
            $where=array('tid'=>$tid);
            $this->_model->del_data($where);
            $this->error("删除成功",U('Tag/index'));
        }


        $this->display();
    }
}